<template>
  <div>dashboard</div>
  <el-input v-model="testInput" placeholder="测试缓存" />
</template>
<!--页面运行初期我们的setup里面的内容会执行一遍相当于我们created,在到我们的onMounted-->
<script setup name="Dashboard">
const testInput = $ref('')
import { useBasicStore } from '@/store/basic'
const { addCachedView } = useBasicStore()
console.log('created11111111')
onMounted(() => {
  const arr = [1, 2, 3, 4]
  arr.forEach((item) => {
    console.log(item)
  })
  a()
})
onUnmounted(() => {
  console.log('onUnmounted')
})

//在页面缓存以后多了onActivated,onDeactivated生命周期
onActivated(() => {
  console.log('onActivated')
})
onDeactivated(() => {
  console.log('onDeactivated')
})

const a = () => {
  console.log('a')
}
//页面被缓存，onActivated,onDeactivated，     onMounted->  页面缓存后onMounted，onUnmounted失效了，onActivated,onDeactivated生效，
//onMounted,  如果页面首次进入被缓存 触发onActivated
</script>
